home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / cexpress / graphic / strline.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-03  |  2.5 KB  |  91 lines

  1. ;void  string_line(strg,dir,col,row,length,color);
  2. ;  unsigned char  *strg,dir,col,row,length,color;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _video_buffer:word
  6.     EXTRN  _snow_protect:byte
  7.  
  8. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  9.     ASSUME  CS:_TEXT
  10.     PUBLIC _string_line
  11. _string_line proc near
  12.     push bp            ;
  13.     mov  bp,sp        ;set stack frame
  14.     push di            ;
  15.     push si            ;
  16.     cmp  _memory_model,0    ;near or far?
  17.     jle  begin        ;jump if near
  18.     inc  bp            ;else add 2 to BP
  19.     inc  bp            ;
  20. begin:    push ds            ;save TURBO's DS
  21.     cld            ;set direction flag
  22.     mov  ax,_video_buffer    ;fetch _video_buffer
  23.     mov  es,ax        ;shift to ES
  24.     sub  ax,ax        ;
  25.     cmp  _memory_model,2    ;data near or far?    
  26.     jb   L0            ;jump if near
  27.     lds  si,dword ptr[bp+4] ;DS:SI pts to Strg
  28.     inc  bp            ;add 2 to BP since dword ptr
  29.     inc  bp            ;
  30.     jmp  short L00        ;
  31. L0:    mov  si,[bp+4]        ;
  32. L00:    mov  [bp+4],si        ;move Strg ptr in FAR case
  33.     mov  al,[bp+10]        ;get ROW value
  34.     dec  ax            ;count from 0
  35.     mov  dl,160        ;160 bytes per line
  36.     mul  dl            ;times number rows
  37.     sub  bx,bx        ;
  38.     mov  bl,[bp+8]        ;get COL value
  39.     mov  di,bx        ;
  40.     dec  di            ;count from 0
  41.     shl  di,1        ;double for attri bytes
  42.     add  di,ax        ;now ES:DI pts to 1st pos
  43.     sub  cx,cx        ;
  44.     mov  cl,[bp+12]        ;string length in CX
  45.     jcxz L7            ;quit if null
  46.     mov  ah,[bp+14]        ;attribute in AH
  47.     mov  bl,[bp+6]        ;get direction param
  48.     mov  dx,158        ;offset for vertical
  49.     cmp  bl,'V'        ;write vertically?
  50.     je   L1            ;jump ahead if so
  51.     cmp  bl,'v'        ;test small 'v' also
  52.     je   L1            ;jump if small 'v'
  53.     sub  dx,dx        ;zero offset if horz
  54. L1:    mov  [bp+14],dx        ;save offset on stack
  55.     cmp  byte ptr[si],0    ;test for null string
  56.     je   L7            ;
  57. L2:    mov  al,[si]        ;get a character
  58.     inc  si            ;forward Strg pointer for next time
  59.     cmp  al,0        ;end of string?
  60.     jne  L3            ;jump ahead if not
  61.     mov  si,[bp+4]        ;pt back to start of Strg
  62.     jmp  short L2        ;go get first char of string
  63. L3:    mov  dx,es        ;ES pts to video buffer
  64.     cmp  dx,0b800h        ;test for graphics card
  65.     jb   L6            ;jump if not graphics
  66.     mov  dx,3dah        ;status byte address
  67.     mov  bx,ax        ;save AX contents
  68. L4:    in   al,dx        ;get status byte
  69.     test al,1        ;test bit
  70.     jnz  L4            ;loop till 0
  71.     cli            ;disable interrupts
  72. L5:    in   al,dx        ;get status byte
  73.     test al,1        ;test bit
  74.     jz   L5            ;loop till 1
  75.     mov  ax,bx        ;restore AX contents
  76. L6:    stosw            ;write a char and attri
  77.     add  di,[bp+14]        ;add offset to next chr
  78.     loop L2            ;go write next
  79.     sti            ;reenable interrupts
  80. L7:    pop  ds            ;
  81.     pop  si            ;
  82.     pop  di            ;
  83.     pop  bp            ;
  84.     cmp  _memory_model,0    ;quit
  85.     jle  quit        ;
  86.     db   0CBh        ;RET far
  87. quit:    ret            ;RET near
  88. _string_line endp
  89. _TEXT    ENDS
  90.     END
  91.